Author Topic: Moving from makefile to C::B project  (Read 5074 times)

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Moving from makefile to C::B project
« on: June 26, 2017, 07:16:13 pm »
I'd like to redo one makefile as a codeblocks project, but I'm not sure if that's possible. The problems are:

1)  options and ifeq

DP_CDDA?=enabled
ifeq ($(DP_CDDA), enabled)
   OBJ_CD=cd_shared.o cd_win.o
else
   OBJ_CD=cd_shared.o cd_null.o
endif

2) different compile flags for some files

dpsoftrast.o: dpsoftrast.c
   $(DO_CC) $(CFLAGS_SSE2)


Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: Moving from makefile to C::B project
« Reply #1 on: June 27, 2017, 03:47:07 am »
1) Depending on how many different configurations you have this could be done with (virtual) targets.

2) You could define a custom build step for a file that specifies different compiler options, but it might be quite cumbersome to replicate all common ones. It might be better to put all files with the same compiler options in one project that produces a static lib and specify the options on project level.

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Moving from makefile to C::B project
« Reply #2 on: June 27, 2017, 01:10:52 pm »
Can't use virtual targets, too many different combinations of options.

Ok, I changed my mind. How to create a codeblocks project that only uses makefile? Tried to File -> New -> Project -> Empty project, it said I must have at least one build target (Debug or Release).

Little feature request, I hope codeblocks would react in some way to opening an empty .cbp file. Like, allow viewing files in this directory, and save a correct project file on exit.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Moving from makefile to C::B project
« Reply #3 on: June 27, 2017, 03:16:01 pm »
Create a empty project (always hit yes and enter a name) go with the targets for the moment...

Then Project->Properties->This is a custom Makefile and you are fine

just out of curiosity: what kind of project is this, that you need different compiler flags for different files, or what flags are those?

greetings

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Moving from makefile to C::B project
« Reply #4 on: June 27, 2017, 03:49:04 pm »
Read stripped down makefile here, https://pastebin.com/DBhd6xHs  , or full version on svn (google darkplaces)

Interesting part starts from prvm_cmds.o: prvm_cmds.c

I'm currently trying to understand it, and throw everything unnecessary out.

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Moving from makefile to C::B project
« Reply #5 on: June 27, 2017, 04:01:27 pm »
Running command: mingw32-make.exe -f makefile Release
mingw32-make.exe: *** No rule to make target 'Release'.  Stop.

How to rename or create build target?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Moving from makefile to C::B project
« Reply #6 on: June 27, 2017, 04:10:42 pm »
Project->Properties->Build targets

this is not sooo complicated to not make it as a cb project.... but using the makefile would be easier, also to keep in sync with the official repo

[EDIT: the path is "Project->Properties->Build targets" not "Project->Build targets"
« Last Edit: June 27, 2017, 04:16:45 pm by BlueHazzard »

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Moving from makefile to C::B project
« Reply #7 on: June 28, 2017, 04:50:15 pm »
New problem: codeblocks runs make from windows terminal, while I only run it from msys2 terminal. Commands like mkdir are now broken, they require \ instead of / as path separator. I need to rewrite makefile now.

Maybe I'll actually move to codeblocks project after all. I need to understand what are those "build scripts" and "Pre/post build steps" with "custom variables" first. And if I can recreate some sort of logic and variables in those prebuild steps.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Moving from makefile to C::B project
« Reply #8 on: July 09, 2017, 11:32:56 pm »
You can set the make program codeblocks uses with

Settings->Compiler->Global compiler settings->Toolchain executables->Make program

note you probably have to click on the white right arrow on the right side of the dialogue to make the "Toolchain executables" tab visible

Quote
Maybe I'll actually move to codeblocks project after all. I need to understand what are those "build scripts" and "Pre/post build steps" with "custom variables" first. And if I can recreate some sort of logic and variables in those prebuild steps.
the wiki is your friend. And note also you can use squirrel scripting, so you have a touring complete programming language on your side to do wired things with the build system. You can use the scripting language also for compiler/ linker options, and i think you can also outsource all this in a script file