Integrate version number into makefile (fixes #6)
Running with --version relied on having a VERSION file in current directory. Having the version number in the makefile ensures it is built into the binary so that --version works all the time.
This commit is contained in:
		
							parent
							
								
									92e8b7b8bf
								
							
						
					
					
						commit
						b93fe31f7e
					
				
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -1,5 +1,7 @@ | ||||
| VERSION = 1.0.0 | ||||
| 
 | ||||
| CC     = gcc | ||||
| CFLAGS = -W -Wall -pedantic -ansi -std=c99 -g | ||||
| CFLAGS = -W -Wall -pedantic -ansi -std=c99 -g -DTS_VERSION=\"$(VERSION)\" | ||||
| 
 | ||||
| LDFLAGS = -lncursesw | ||||
| 
 | ||||
|  | ||||
| @ -8,6 +8,10 @@ | ||||
| #include "keyboard.h" | ||||
| #include "common.h" | ||||
| 
 | ||||
| #ifndef TS_VERSION | ||||
| #define TS_VERSION "n/a" | ||||
| #endif | ||||
| 
 | ||||
| const char *program_name; | ||||
| struct game game; | ||||
| 
 | ||||
| @ -123,16 +127,5 @@ void usage(const char *program_name) { | ||||
| } | ||||
| 
 | ||||
| void version() { | ||||
|   FILE *version_file; | ||||
|   char version_string[6]; | ||||
| 
 | ||||
|   if (!(version_file = fopen("VERSION", "rb"))) { | ||||
|     tty_solitaire_generic_error(errno, __FILE__, __LINE__); | ||||
|   } | ||||
|   if (!fread(version_string, 1, 5, version_file)) { | ||||
|     // TODO: handle this.
 | ||||
|   } | ||||
|   version_string[5] = '\0'; | ||||
|   printf("%s\n", version_string); | ||||
|   fclose(version_file); | ||||
|   printf("%s\n", TS_VERSION); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user