Makefile: automatically rebuild when the CFLAGS, version or label changes
This commit is contained in:
		
							parent
							
								
									8969230999
								
							
						
					
					
						commit
						f89b679224
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -13,3 +13,4 @@
 | 
				
			|||||||
/src/version.c
 | 
					/src/version.c
 | 
				
			||||||
/src/*.tgz
 | 
					/src/*.tgz
 | 
				
			||||||
/src/Grafx2.app
 | 
					/src/Grafx2.app
 | 
				
			||||||
 | 
					/src/.*.cache
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								src/Makefile
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								src/Makefile
									
									
									
									
									
								
							@ -1,5 +1,6 @@
 | 
				
			|||||||
#  Grafx2 - The Ultimate 256-color bitmap paint program
 | 
					#  Grafx2 - The Ultimate 256-color bitmap paint program
 | 
				
			||||||
#  
 | 
					#  
 | 
				
			||||||
 | 
					#  Copyright 2018 Thomas Bernard
 | 
				
			||||||
#  Copyright 2012 Franck Charlet
 | 
					#  Copyright 2012 Franck Charlet
 | 
				
			||||||
#  Copyright 2011 Pawel Góralski
 | 
					#  Copyright 2011 Pawel Góralski
 | 
				
			||||||
#  Copyright 2009 Per Olofsson
 | 
					#  Copyright 2009 Per Olofsson
 | 
				
			||||||
@ -35,6 +36,16 @@
 | 
				
			|||||||
# Detect GIT revision
 | 
					# Detect GIT revision
 | 
				
			||||||
  GIT_REVISION = $(shell git rev-list --count 1af8c74f53110e349d8f0d19b14599281913f71f..)
 | 
					  GIT_REVISION = $(shell git rev-list --count 1af8c74f53110e349d8f0d19b14599281913f71f..)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  REVISION_CACHE = .revision.cache
 | 
				
			||||||
 | 
					  RES := $(shell if [ ! -f $(REVISION_CACHE) ] || [ "`cat $(REVISION_CACHE)`" != "$(GIT_REVISION)" ] ; then echo "$(GIT_REVISION)" > $(REVISION_CACHE) ; fi )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ifneq (,$(LABEL))
 | 
				
			||||||
 | 
					  LABEL_CACHE = .label.cache
 | 
				
			||||||
 | 
					  RES := $(shell if [ ! -f $(LABEL_CACHE) ] || [ "`cat $(LABEL_CACHE)`" != "$(LABEL)" ] ; then echo "$(LABEL)" > $(LABEL_CACHE) ; fi )
 | 
				
			||||||
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  CFLAGS_CACHE = .cflags.cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### PLATFORM DETECTION AND CONFIGURATION ###
 | 
					### PLATFORM DETECTION AND CONFIGURATION ###
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PLATFORMOBJ =
 | 
					PLATFORMOBJ =
 | 
				
			||||||
@ -504,7 +515,7 @@ endif
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### And now for the real build rules ###
 | 
					### And now for the real build rules ###
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.PHONY : all debug release clean depend zip version force install uninstall
 | 
					.PHONY : all debug release clean depend zip force install uninstall
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is the list of the objects we want to build. Dependancies are built by "make depend" automatically.
 | 
					# This is the list of the objects we want to build. Dependancies are built by "make depend" automatically.
 | 
				
			||||||
OBJS = main.o init.o graph.o sdlscreen.o misc.o special.o \
 | 
					OBJS = main.o init.o graph.o sdlscreen.o misc.o special.o \
 | 
				
			||||||
@ -652,17 +663,15 @@ endif
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Make release will strip the executable to make it smaller but non-debugable
 | 
					# Make release will strip the executable to make it smaller but non-debugable
 | 
				
			||||||
release : version $(BIN)
 | 
					release : $(BIN)
 | 
				
			||||||
	$(STRIP) $(BIN)
 | 
						$(STRIP) $(BIN)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create a zip archive ready for upload to the website, including binaries and sourcecode
 | 
					# Create a zip archive ready for upload to the website, including binaries and sourcecode
 | 
				
			||||||
ziprelease: version $(BIN) release
 | 
					ziprelease: release $(OBJDIR)/versiontag
 | 
				
			||||||
	echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.$(GIT_REVISION) | tr " :" "_-" | sed -e "s/\([wW][iI][pP]\)\\./\1/" > $(OBJDIR)/versiontag
 | 
					 | 
				
			||||||
	cd .. && $(TAR) czf "src-`cat $(OBJDIR:../%=%)/versiontag`.tgz" src/*.c src/*.cpp src/*.h src/Makefile src/Makefile.dep src/gfx2.ico src/Grafx2_Prefix.pch src/SDLMain.m
 | 
						cd .. && $(TAR) czf "src-`cat $(OBJDIR:../%=%)/versiontag`.tgz" src/*.c src/*.cpp src/*.h src/Makefile src/Makefile.dep src/gfx2.ico src/Grafx2_Prefix.pch src/SDLMain.m
 | 
				
			||||||
	cd .. && $(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR:../%=%)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN:../%=%) share/grafx2/gfx2def.ini $(SCRIPT_FILES:../%=%) $(SKIN_FILES:../%=%) share/grafx2/gfx2.gif share/icons/grafx2.svg doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt doc/PF_fonts.txt $(FONT_FILES:../%=%) doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt doc/README-lua.txt src-`cat $(OBJDIR:../%=%)/versiontag`.tgz $(PLATFORMFILES:../%=%)
 | 
						cd .. && $(ZIP) $(ZIPOPT) "grafx2-`cat $(OBJDIR:../%=%)/versiontag`$(TTFLABEL)-$(PLATFORM).$(ZIP)" $(BIN:../%=%) share/grafx2/gfx2def.ini $(SCRIPT_FILES:../%=%) $(SKIN_FILES:../%=%) share/grafx2/gfx2.gif share/icons/grafx2.svg doc/README.txt doc/COMPILING.txt doc/gpl-2.0.txt doc/PF_fonts.txt $(FONT_FILES:../%=%) doc/README-zlib1.txt doc/README-SDL.txt doc/README-SDL_image.txt doc/README-SDL_ttf.txt doc/README-lua.txt src-`cat $(OBJDIR:../%=%)/versiontag`.tgz $(PLATFORMFILES:../%=%)
 | 
				
			||||||
	$(DELCOMMAND) "../src-`cat $(OBJDIR)/versiontag`.tgz"
 | 
						$(DELCOMMAND) "../src-`cat $(OBJDIR)/versiontag`.tgz"
 | 
				
			||||||
	$(TAR) czf "../grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" $(TARTRANSFORM) ../src/*.c ../src/*.cpp ../src/*.h ../src/Makefile ../src/Makefile.dep ../share/grafx2/gfx2def.ini $(SCRIPT_FILES) $(SKIN_FILES) ../src/gfx2.ico ../share/grafx2/gfx2.gif ../share/icons/grafx2.svg ../doc/README.txt ../doc/COMPILING.txt ../doc/gpl-2.0.txt ../doc/PF_fonts.txt ../misc/unix/grafx2.1 ../misc/unix/grafx2.xpm ../misc/unix/grafx2.desktop ../misc/morphos/grafx2.info $(FONT_FILES) ../src/Grafx2_Prefix.pch ../src/SDLMain.m
 | 
						$(TAR) czf "../grafx2-`cat $(OBJDIR)/versiontag`$(TTFLABEL)-src.tgz" $(TARTRANSFORM) ../src/*.c ../src/*.cpp ../src/*.h ../src/Makefile ../src/Makefile.dep ../share/grafx2/gfx2def.ini $(SCRIPT_FILES) $(SKIN_FILES) ../src/gfx2.ico ../share/grafx2/gfx2.gif ../share/icons/grafx2.svg ../doc/README.txt ../doc/COMPILING.txt ../doc/gpl-2.0.txt ../doc/PF_fonts.txt ../misc/unix/grafx2.1 ../misc/unix/grafx2.xpm ../misc/unix/grafx2.desktop ../misc/morphos/grafx2.info $(FONT_FILES) ../src/Grafx2_Prefix.pch ../src/SDLMain.m
 | 
				
			||||||
	$(DELCOMMAND) "$(OBJDIR)/versiontag"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(BIN) : $(OBJ)
 | 
					$(BIN) : $(OBJ)
 | 
				
			||||||
	@test -d ../bin || $(MKDIR) ../bin
 | 
						@test -d ../bin || $(MKDIR) ../bin
 | 
				
			||||||
@ -674,24 +683,20 @@ ifeq ($(PLATFORM),Haiku)
 | 
				
			|||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# GIT revision number
 | 
					# GIT revision number
 | 
				
			||||||
version.c :
 | 
					version.c:	$(REVISION_CACHE)
 | 
				
			||||||
	echo "char SVN_revision[]=\"$(GIT_REVISION)\";" > version.c
 | 
						echo "char SVN_revision[]=\"$(GIT_REVISION)\";" > version.c
 | 
				
			||||||
ifeq ($(LABEL),)
 | 
					
 | 
				
			||||||
else
 | 
					ifneq ($(LABEL),)
 | 
				
			||||||
 | 
					pversion.c:	$(LABEL_CACHE)
 | 
				
			||||||
	echo "char Program_version[]=\"$(LABEL)\";" > pversion.c
 | 
						echo "char Program_version[]=\"$(LABEL)\";" > pversion.c
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
version : delversion delpversion version.c pversion.c $(OBJDIR)/version.o $(OBJDIR)/pversion.o all
 | 
					$(OBJDIR)/versiontag: pversion.c $(REVISION_CACHE)
 | 
				
			||||||
 | 
						echo `sed "s/.*=\"\(.*\)\";/\1/" pversion.c`.$(GIT_REVISION) | tr " :" "_-" | sed -e "s/\([wW][iI][pP]\)\\./\1/" > $(OBJDIR)/versiontag
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RES := $(shell if [ ! -f $(CFLAGS_CACHE) ] || [ "`cat $(CFLAGS_CACHE)`" != "$(COPT) $(CFLAGS)" ] ; then echo "$(COPT) $(CFLAGS)" > $(CFLAGS_CACHE) ; fi )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
delversion :
 | 
					$(OBJ):	$(CFLAGS_CACHE)
 | 
				
			||||||
	$(DELCOMMAND) version.c
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
delpversion :
 | 
					 | 
				
			||||||
ifeq ($(LABEL),)
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
	$(DELCOMMAND) pversion.c
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(OBJDIR)/%.o : %.c
 | 
					$(OBJDIR)/%.o : %.c
 | 
				
			||||||
	$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
 | 
						$(if $(wildcard $(OBJDIR)),,$(MKDIR) $(OBJDIR))
 | 
				
			||||||
@ -714,6 +719,7 @@ $(OBJDIR)/haiku.o : haiku.cpp
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
clean :
 | 
					clean :
 | 
				
			||||||
	$(DELCOMMAND) $(OBJ)
 | 
						$(DELCOMMAND) $(OBJ)
 | 
				
			||||||
 | 
						$(DELCOMMAND) $(OBJDOR)/versiontag
 | 
				
			||||||
	$(DELCOMMAND) $(BIN)
 | 
						$(DELCOMMAND) $(BIN)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifneq ($(PLATFORM),amiga-vbcc)
 | 
					ifneq ($(PLATFORM),amiga-vbcc)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user