daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Aug 15th, 2018 67 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. gnu make : how to make conditional cflags
  2. CFLAGS = -g -O0 -Wall -std=c99
  3.  
  4. CC =    gcc
  5. CPP =   g++
  6. LIBS =
  7.  
  8. PBDUMPER = pbdumper.exe
  9.  
  10. all: $(PBDUMPER)
  11.  
  12. $(PBDUMPER): pbdumper.c
  13.     $(CC) $(CFLAGS) -o $@ $< $(LIBS)
  14.  
  15. clean:
  16.     rm -f $(PBDUMPER)
  17.  
  18. .PHONY: clean
  19.    
  20. CFLAGS_COMMON = -std=c99
  21. CFLAGS_DEBUG = -g -O0 -Wall
  22. CFLAGS_RELEASE = -O2 -Wall
  23. ...
  24. $(PBDUMPER): pbdumper.c
  25.     $(CC) $(CFLAGS_COMMON) $(CFLAGS_DEBUG) -o $@ $< $(LIBS)
  26.    
  27. CFLAGS = -std=c99
  28. # Release
  29. # CFLAGS += -O2 -Wall
  30. # Debug
  31. CFLAGS += -g -O0 -Wall
  32.    
  33. ifeq ($(build),release)
  34.     CFLAGS += -O2 -Wall
  35. else
  36.     CFLAGS += -g -O0 -Wall
  37. endif
  38.    
  39. #debug is default, for another flavor : make BUILD=release
  40. BUILD := debug
  41.  
  42. cflags.common := -std=c99
  43. cflags.debug := -g -O0 -Wall
  44. cflags.release := -O2 -Wall
  45. CFLAGS := ${cflags.${BUILD}} ${cflags.common}
  46. LIBS =
  47.  
  48. CC =    gcc
  49. CPP =   g++
  50.  
  51. #executable
  52. PBDUMPER = pbdumper.exe
  53.  
  54. all: $(PBDUMPER)
  55.  
  56. $(PBDUMPER): pbdumper.c
  57.     $(CC) $(CFLAGS) -o $@ $< $(LIBS)
  58.  
  59. clean:
  60.     rm -f $(PBDUMPER)
  61.  
  62. .PHONY: clean all
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top