Pelles C migration aid tool
- [ ] Parse and convert Pelles C project files (.PPJ) to Makefiles
- [ ] Automatically modify the generated Makefiles to build with Orange C
Pelles C project file (.PPJ) is a dialect of Makefile. Please have a look at a simple .PPJ:
#
# PROJECT FILE generated by "Pelles C for Windows, version 13.00".
# WARNING! DO NOT EDIT THIS FILE.
#
POC_PROJECT_VERSION = 9.00#
POC_PROJECT_TYPE = 3#
POC_PROJECT_MODE = Release#
POC_PROJECT_RESULTDIR = .#
POC_PROJECT_OUTPUTDIR = output#
!if "$(POC_PROJECT_MODE)" == "Release"
POC_PROJECT_ARGUMENTS = #
CC = pocc.exe#
RC = porc.exe#
LINK = polink.exe#
CCFLAGS = -Tx86-coff -Ot -W1 -Gd -std:C99#
RCFLAGS = -r#
LINKFLAGS = -machine:ix86 -subsystem:console kernel32.lib advapi32.lib#
ASFLAGS = -AIA32 -Gd#
AS = poasm.exe#
SIGNFLAGS = -location:CU -store:MY -timeurl:http://timestamp.verisign.com/scripts/timstamp.dll -errkill#
SIGN = posign.exe#
INCLUDE = $(PellesCDir)\Include\Win;$(PellesCDir)\Include#
LIB = $(PellesCDir)\Lib\Win;$(PellesCDir)\Lib#
POC_PROJECT_ZIPEXTRA = #
POC_PROJECT_EXECUTOR = #
POC_PROJECT_WORKPATH = #
!elseif "$(POC_PROJECT_MODE)" == "Debug"
POC_PROJECT_ARGUMENTS = #
CC = pocc.exe#
RC = porc.exe#
LINK = polink.exe#
CCFLAGS = -Tx86-coff -Ot -W1 -Gd -std:C99 -Zi#
RCFLAGS = -r#
LINKFLAGS = -machine:ix86 -subsystem:console kernel32.lib advapi32.lib -debug -debugtype:po#
ASFLAGS = -AIA32 -Gd -Zi#
AS = poasm.exe#
SIGNFLAGS = -location:CU -store:MY -timeurl:http://timestamp.verisign.com/scripts/timstamp.dll -errkill#
SIGN = posign.exe#
INCLUDE = $(PellesCDir)\Include\Win;$(PellesCDir)\Include#
LIB = $(PellesCDir)\Lib\Win;$(PellesCDir)\Lib#
POC_PROJECT_ZIPEXTRA = #
POC_PROJECT_EXECUTOR = #
POC_PROJECT_WORKPATH = #
!else
!error "Unknown mode."
!endif
#
# Build hello.EXE.
#
hello.EXE: \
output\hello.OBJ
$(LINK) $(LINKFLAGS) -out:"$@" $**
#
# Build hello.OBJ.
#
output\hello.OBJ: \
hello.c
$(CC) $(CCFLAGS) "$!" -Fo"$@"
.SILENT:
Originally posted by @yh15kla9 in https://github.com/LADSoft/OrangeC/discussions/1085
these look like standard make files.... the trick is they are highly customized for the PELLES C environment. Possibly, if you install Pelles C and Orange C side by side then go to a directory with one of these files, with a minor change you could run omake and use it to build your pelles C project with pelles C.
the key lines are down where it says Build Hello.EXE and below. Everything above that is the equivalent of a C language #define statement. '#' characters start a comment so here every line ends with a comment.
considering this rule:
output\hello.OBJ: \
hello.c
$(CC) $(CCFLAGS) "$!" -Fo"$@"
the $(CC) and $(CCFLAGS) and "$!" and $@" get macro expanded (the rules for expansion are similar to but more powerful than similar #define expansions) and from the above we have:
"$!" gets expanded to the first thing after the colon: hello.c (this would have to be changed as OCC uses "$<" instead to conform with gnu make) "$@" means use the name before the colon, e.g. output]hello.OBJ
so the entire thing gets expanded to:
pocc.exe Tx86-coff -Ot -W1 -Gd -std:C99 "hello.c" -Fo:output\hello.OBJ
likewise for hello.exe the macro "$**" doesn't exist in omake and should be replaced with "$^". It means take ALL names after the : but here there is only one.
The expansion then is:
polink -machine:ix86 -subsystem:console kernel32.lib advapi32.lib -out:"hello.exe" "output\hello.obj"
Working backwards for this simple example you could make the following small make file: (link flags don't matter as all the libraries are built in anyway and the only machine is x86)
CCFLAGS = -c -9
LINKFLAGS =
CC=occ.exe
LINK=occ.exe
hello.exe: output\hello.o
$(LINK) $(LINKFLAGS) $< -o $@
output\hello.o: hello.c
$(CC) $(CCFLAGS) $^ -o $@
yeah you could use olink but it gets more complicated, occ handles various flags and things you need and then links automagically anyway...
all this is easy to automate, the only difficulty is details like how to translate the compiler/linker flags and so forth. A lot of the times they won't matter so much though like in this case we could compile hello world much more easily....
I think i got the $< and $^ backwards in the sample makefile i madee...