-3

Can we write a makefile which is able to create debug/ release build . The user will give choice which one should be made.

  • Yes of course you can. Just have two targets, one for release and one for debug. – kaylum Mar 19 '21 at 10:19
  • 1
    Does [this](https://stackoverflow.com/questions/1079832/how-can-i-configure-my-makefile-for-debug-and-release-builds) answer your question? – icebp Mar 19 '21 at 10:19
  • Does this answer your question? [How can I configure my makefile for debug and release builds?](https://stackoverflow.com/questions/1079832/how-can-i-configure-my-makefile-for-debug-and-release-builds) – icebp Mar 19 '21 at 10:19
  • have a look at https://github.com/cppfw/prorab it provides creating as many configs as you want, building each of them in separate directory – igagis Mar 19 '21 at 22:43

2 Answers2

0

you can use as @kaylum said and use different cflags. every target will get it's own cflags

CFLAGS1 = -ansi -pedantic-errors -Wall -Wextra -g

CFLAGS2 = -ansi -pedantic-errors -Wall -Wextra -DNDEBUG -O3
Asaf Itach
  • 300
  • 6
  • 13
0

I struggled about it and couldn't find the best answer.My solution creates executables in different directories without mixing them. Here is the answer

Kanony
  • 509
  • 2
  • 12