Skip to content

Instantly share code, notes, and snippets.

@scolton99
Created February 23, 2026 16:11
Show Gist options
  • Select an option

  • Save scolton99/7c6144e7736215534b5884ce8610da42 to your computer and use it in GitHub Desktop.

Select an option

Save scolton99/7c6144e7736215534b5884ce8610da42 to your computer and use it in GitHub Desktop.
Updated Makefile for the "errorcodes" prc-tools sample project to avoid relying on nondeterministic output order from find.
# Makefile: Convert Palm OS error codes into symbolic error names.
#
# Copyright (c) 2001 John Marshall.
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
all: errordb errorcodes.prc
errorcodes_crid = ErrC
errorcodes_postobjs = errorcodes errorcodes.ro errors.ro
errorcodes.prc: $(errorcodes_postobjs)
build-prc -n ErrorCodes -c $(errorcodes_crid) $(errorcodes_postobjs)
errorcodes_defs = -Derrorcodes_crid="'$(errorcodes_crid)'" \
-Dmsglen_max=`grep '^MAXLEN' < errors.rcp | sed 's/.* //'`
errorcodes: errorcodes.c errorcodes.h errors.rcp
m68k-palmos-gcc -g -Wall $(errorcodes_defs) -o errorcodes errorcodes.c
PILRCFLAGS = -q -allowEditID
errorcodes.ro: errorcodes.rcp errorcodes.h bigicon.pbitm
errors.ro: errors.rcp errorcodes.h
errordb errors.rcp: errorlist gendbstrings
perl gendbstrings errordb errorlist > errors.rcp
errorlist: list-errordefs
./list-errordefs | sort > errorlist
list-errordefs: list-errordefs.c
list-errordefs.c: list-errordefs.i generrordefs
perl generrordefs list-errordefs.i > list-errordefs.c
list-errordefs.i: list-all.i
egrep '(^# |ErrorClass)' list-all.i > list-errordefs.i
# Convert the few error classes that are defined via enums (which is better
# for debuggers, but harder for us) to #defines so they will be picked up
# by later passes. The first word in each pair is used as a trigger to tell
# enum2defines to start converting, and the second is what to use as a base
# for the duration of each conversion.
TRIGGERS = hostErrBase:hostErrorClass gsmErrorClass:gsmErrorClass
list-all.i: list-allraw.i enum2defines
perl enum2defines $(TRIGGERS) < list-allraw.i > list-all.i
list-allraw.i: list-includeall.c
m68k-palmos-gcc -E -C -dD $(AVOIDS) list-includeall.c > list-allraw.i
# Avoid SerialMgrOld.h because it just duplicates a few error codes in
# SerialMgr.h. Avoid CharShiftJIS.h because it doesn't contain any error
# codes and makes lots of "macro redefined" warnings due to conflicts with
# CharLatin.h. Avoid HostControl because we're going to do it separately.
# Avoid 68000Instrs.h because it #defines _DbgBreak, thus conflicting with
# DebugMgr.h -- and it doesn't have a macro guard :-( Avoid the Simulator's
# Locale/Locale_xxYY files because they all conflict with BuildDefaults.h.
# Avoid SonyChars.h because the 5.0 SDK's Chars.h conflicts with it.
AVOIDS = -D__SERIALMGROLD_H_ -D__CHARSHIFTJIS_H__ -D_HOSTCONTROL_H_ \
-D__SONYCHARS_H__
list-includeall.c: list-filelist
(sed 's/.*/#include "&"/' list-filelist; \
echo '#undef _HOSTCONTROL_H_'; \
echo '#include "HostControl.h"') > list-includeall.c
list-filelist: SHELL:=/bin/bash
list-filelist: list-topdirs
( all=$$(cat list-topdirs); \
for dir in $${all[@]}; do \
if [[ -d "$$dir" ]]; then \
i=0; \
while results=$$(find "$$dir" -mindepth $$i -maxdepth $$i) && [[ -n "$$results" ]]; do \
while IFS= read -r line; do \
[[ -f "$$line" ]] && [[ $$line == *.h ]] && echo "$$line"; \
done <<< "$$results"; \
((i++)); \
done; \
fi; \
done; ) | \
grep -v 68000Instrs.h | grep -v Simulator/Locale > list-filelist
list-topdirs:
echo '#include <ErrorMgr.h>' | \
m68k-palmos-gcc -H -E - 2>&1 >/dev/null | head -1 | \
sed 's:^\(\(.*\)/sdk[^/]*\)/include.*:\1/include \2/include:' > $@
.SUFFIXES: .ro .rcp
.rcp.ro:
pilrc $(PILRCFLAGS) -ro -o $@ $<
clean:
-rm -f errordb errorlist list-*
-rm -f errors.rcp *.ro *.o errorcodes *.prc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment