Author Topic: manually converting makefile to cb project  (Read 2718 times)

Offline shenc

  • Single posting newcomer
  • *
  • Posts: 6
manually converting makefile to cb project
« on: August 26, 2020, 10:36:33 pm »
I know this is not a easy job but for some reason I want give it a try.
in the makefile there are a lot of defined variable such as
MAJOR=2
MINOR=0
REV=0
PATCH=0
VERSION=${MAJOR}.${MINOR}.${REV}.${PATCH}
CFLAGS+= -DVERSION='"${MAJOR}.${MINOR}.${REV}.${PATCH}"'
HOME=/home/myhome
CFLAGS+= -I${HOME}/module/xyz
%.o: ${HOME}/module/xyz/src/%.c
$(CC) -c $(CFLAGS) -o $@ $<

In CB, where can I set those variable as HOME, CFLAGS, VERSION, etc. 
Can I set them in "settings"->"compiler settings"->"#defines"
HOME=/home/myhome
MAJOR=2
MINOR=0
REV=0
PATCH=0
VERSION=${MAJOR}.${MINOR}.${REV}.${PATCH}

Then use them in "settings"->"compiler settings"->"other options" as
-I${HOME}/module/xyz  -DVERSION='"${VERSION}"'


Thanks


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: manually converting makefile to cb project
« Reply #1 on: August 26, 2020, 11:00:50 pm »
Quote
I know this is not a easy job but for some reason I want give it a try.
Trying is always good, so you can learn things

Quote
"settings"->"compiler settings"->"#defines"
Always use Projects, never modify the compiler settings.
If you want to use the project as a template for more projects, you can save the project as template and reuse it after...

For variables that remain constant on the machine, like paths, codeblocks has the concept of global variables: Settings->global Variables
There you can create a new Variable  and on the right define your sub variables. Later you can use them like ${VAR_NAME.SUB_VAR_NAME} nearly everywhere in codeblocks
If you have per project variables, like version, they should be in Project->Build options->Select the project name on the left->Custom variables. Then you can use this variables like above ${VAR_NAME}

You can use them later in in the Project->Build options->compiler->#defines or in linker and compiler settings

i am not sure, if you can use variables in Project->Build options->Select the project name on the left->Custom variables to combine new variables....