Shop OBEX P1 Docs P2 Docs Learn Events
Makefile question regarding Simple Library — Parallax Forums

Makefile question regarding Simple Library

DavidZemonDavidZemon Posts: 2,973
edited 2014-02-19 18:20 in Propeller 1
I would like to give PropWare the ability to hook into the Simple Library. However, the header files in Simple Library contain relative path includes instead of system includes. For instance, simpletools.h has a line:
#include "simpletext.h"
This is something I don't know how to deal with. Obviously, simpletext.h is not in the folder that Make expects it to be.

One (ugly) option is to repackage the entire Learn folder with PropWare and modify the source files to work as expected. I'm not a big fan of this option. If I were to do it though, I would probably just refactor the entire Learn folder and incorporate it into PropWare 100% (move folders around and build all of it into the already existing PropWare library). This is no good though, and only a last-ditch resort.

Does anyone else know of a way to make this work?

(I've just pushed an Example project to release-2.0-nightly branch that has my current work)

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-02-18 11:56
    Does anyone else know of a way to make this work?

    Simple Libraries are not designed for "simple" Makefiles.
    You will need to use some $(shell blah) commands to get what you want.

    Consider this which can be optimized, but is a starting point:
    WHOAMI := $(shell whoami)
    MYIAWK=awk '{ {print "-L";print $0} }'
    MYLAWK=awk '{ {print "-L";print $0} }'
    
    INCLUDES := $(shell ls -RF | grep ":" | grep -v "html:" | grep -v "cmm:" | grep -v "xmm.:" | cut -d":" -f1 | $(MYIAWK))
    
    CMM_LIBS := $(shell ls -RF | grep "cmm:" | cut -d":" -f1 | $(MYLAWK))
    
    LMM_LIBS := $(shell ls -RF | grep "lmm:" | cut -d":" -f1 | $(MYLAWK))
    
    XMMC_LIBS := $(shell ls -RF | grep "xmmc:" | cut -d":" -f1 | $(MYLAWK))
    
    XMMSING_LIBS := $(shell ls -RF | grep "single:" | cut -d":" -f1 | $(MYLAWK))
    
    XMMSPLT_LIBS := $(shell ls -RF | grep "split:" | cut -d":" -f1 | $(MYLAWK))
    
    all:
        @echo "Example command output: whoami? $(WHOAMI)"
        @echo ""
        @echo "Include folders: $(INCLUDES)"
        @echo ""
        @echo "CMM Library folders: $(CMM_LIBS)"
        @echo ""
        @echo "LMM Library folders: $(LMM_LIBS)"
        @echo ""
        @echo "XMMC Library folders: $(XMMC_LIBS)"
        @echo ""
        @echo "XMM_SINGLE Library folders: $(XMMSING_LIBS)"
        @echo ""
        @echo "XMM_SPLIT  Library folders: $(XMMSPLT_LIBS)"
        @echo ""
    
    Output:
    sh-3.1$ make
    Example command output: whoami? Steve
    
    
    Include folders: -I . -I ./Audio -I ./Audio/libwavplayer -I ./Audio/libwavplayer/lmm -I ./Convert -I ./Convert/libadcACpropab -I /Convert/libadcACpropab/lmm -I ./Convert/libadcDCpropab -I ./Convert/libadcDCpropab/lmm -I ./Convert/libdacctr -I ./Convert/libdacctr/lmm -I ./Display -I ./Display/libvgatext -I ./Display/libvgatext/lmm -I ./Motor -I ./Motor/libservo -I ./Motor/libservo/lmm -I ./Motor/libservoAux -I ./Motor/libservoAux/lmm -I ./Motor/libservodiffdrive -I ./Motor/libservodiffdrive/lmm -I ./Protocol -I ./Protocol/libsimplei2c -I ./Protocol/libsimplei2c/lmm -I ./Robotics -I ./Robotics/ActivityBot -I ./Robotics/ActivityBot/libabcalibrate -I ./Robotics/ActivityBot/libabdrive -I ./Robotics/ActivityBot/libabdrive/lmm -I ./Sensor -I ./Sensor/libcompass3d -I ./Sensor/libcompass3d/lmm -I ./Sensor/libmx2125 -I ./Sensor/libmx2125/lmm -I ./Sensor/libping -I ./Sensor/libping/lmm -I ./Text Devices -I ./Text Devices/libfdserial -I ./Text Devices/libfdserial/lmm -I ./Text Devices/libsimpletext -I ./Text Devices/libsimpletext/lmm -I ./Utility -I ./Utility/libmstimer -I ./Utility/libmstimer/lmm -I ./Utility/libsimpletools -I ./Utility/libsimpletools/lmm -I ./Utility/libsimpletools/source
    
    CMM Library folders: -L ./Audio/libwavplayer/cmm -L ./Convert/libadcACpropab/cmm -L ./Convert/libadcDCpropab/cmm -L ./Convert/libdacctr/cmm -L ./Display/libvgatext/cmm -L ./Motor/libservo/cmm -L ./Motor/libservoAux/cmm -L ./Motor/libservodiffdrive/cmm -L ./Protocol/libsimplei2c/cmm -L ./Robotics/ActivityBot/libabcalibrate/cmm -L ./Robotics/ActivityBot/libabdrive/cmm -L ./Sensor/libcompass3d/cmm -L ./Sensor/libmx2125/cmm -L ./Sensor/libping/cmm -L
     ./Text Devices/libfdserial/cmm -L ./Text Devices/libsimpletext/cmm -L ./Utility/libmstimer/cmm -L ./Utility/libsimpletools/cmm
    
    LMM Library folders: -L ./Audio/libwavplayer/lmm -L ./Convert/libadcACpropab/lmm -L ./Convert/libadcDCpropab/lmm -L ./Convert/libdacctr/lmm -L ./Display/libvgatext/lmm -L ./Motor/libservo/lmm -L ./Motor/libservoAux/lmm -L ./Motor/libservodiffdrive/lmm -L ./Protocol/libsimplei2c/lmm -L ./Robotics/ActivityBot/libabdrive/lmm -L ./Sensor/libcompass3d/lmm -L ./Sensor/libmx2125/lmm -L ./Sensor/libping/lmm -L ./Text Devices/libfdserial/lmm -L ./Text Devices/libsimpletext/lmm -L ./Utility/libmstimer/lmm -L ./Utility/libsimpletools/lmm
    
    XMMC Library folders: -L ./Convert/libadcACpropab/xmmc -L ./Convert/libadcDCpropab/xmmc -L ./Display/libvgatext/xmmc -L ./Protocol/libsimplei2c/xmmc -L ./Sensor/libcompass3d/xmmc -L ./Sensor/libmx2125/xmmc -L ./Sensor/libping/xmmc -L ./Text Devices/libfdserial/xmmc -L ./Text Devices/libsimpletext/xmmc -L ./Utility/libsimpletools/xmmc
    
    XMM_SINGLE Library folders:
    
    XMM_SPLIT  Library folders:
    
    sh-3.1$
    
    Why does this stupid forum editor always add two line breaks for "\r\n" ?
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-02-18 12:12
    Thanks Jazzed. I'll brainstorm quietly on this for a while... platform cross-compatibility is going to be "fun".
  • jazzedjazzed Posts: 11,803
    edited 2014-02-18 12:31
    Thanks Jazzed. I'll brainstorm quietly on this for a while... platform cross-compatibility is going to be "fun".
    That Makefile was developed entirely on my PC that has MSYS and Mingw installed.

    The Makefile needs some additional targets for building all those libraries of course ....
    It would be wonderful if you could contribute that ;)
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-02-18 18:04
    1. What do you mean by additional targets to build the libraries? The library binary files are already present and usable in all situations correct?
    2. I'm thinking of writing a script for my local machine that downloads the latest Simple Library, copies all source files into my local PropWare directory and renames them appropriately in a directory hierarchy that matches the current setup. This isn't ideal... but I'm very afraid of how long it's going to take to compile this seemingly small library with a script like the above once I take into account cross-platform compatibility
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-02-18 21:14
    Progress is being made but I'll have to call it quits til tomorrow evening. I've decided to import Simple Library into PropWare. I can not think of any better way to do this... the file hierarchy just isn't set up for Make at all.

    I can think of some other ways to make it work, but they would add extra requisite knowledge for using PropWare or make existing projects that utilize Simple Library incompatible, which I don't want to do.

    The current plan should result is line-for-line compatibility with existing projects using Simple Library. All header files will exist in the the PropWare root and all source files will exist in <propware_root>/simple_source. Tomorrow's work revolves around creating a libSimple_<mem_model>.a for each memory model and dropping it in <propware_root>/<mem_model>, right next to libPropWare_<mem_model>.a.

    I am open to other ideas if they're out there.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-02-19 17:32
    WOO! I can now run the I2C demo program (no idea if it works correctly - but it compiles) from within PropWare. :cool: I've pushed an updated v2.0-nightly branch that has all of the Simple files as well as a Python script to do the importing. I've only added the Python script to the repo for a couple reasons - 1) anyone who wishes to use their own version of Simple can, and 2) if a new version of Simple is released and someone is very eager to use it within PropWare before I push an update to PropWare.

    Any existing Simple IDE projects making use of the Simple Library should be 98% code compatible with this build system - just write yourself a quick Makefile based on the I2C example or any other and you'll be good to go.

    One change I had to make that I am not entirely comfortable with is setting the 32-bit doubles option (it's required by at least one file in the Simple Library). I'm guessing the answer is no, but is it possible to compile Simple with 32-bit doubles and everything else with either 32- or 64-bit doubles and have it all linked into a single executable, or does everything need to match?

    Now, to go import some more Simple Library demo projects into PropWare and verify that they work.
  • jazzedjazzed Posts: 11,803
    edited 2014-02-19 18:13
    One change I had to make that I am not entirely comfortable with is setting the 32-bit doubles option (it's required by at least one file in the Simple Library). I'm guessing the answer is no, but is it possible to compile Simple with 32-bit doubles and everything else with either 32- or 64-bit doubles and have it all linked into a single executable, or does everything need to match?

    Everything needs to match. Simple Libraries are designed mostly for small size and use within the education environment. While the print() function is bigger than printf() for simple parameters, it never grows beyond 6KB like printf does (30KB with 64bit doubles and -lm) and does not need the math library for doing floating-point (not that we really needs that, but it is an education requirement). The 32-bit doubles requirement was selected for smaller size.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-02-19 18:20
    jazzed wrote: »
    Everything needs to match. Simple Libraries are designed mostly for small size and use within the education environment. While the print() function is bigger than printf() for simple parameters, it never grows beyond 6KB like printf does (30KB with 64bit doubles and -lm) and does not need the math library for doing floating-point (not that we really needs that, but it is an education requirement). The 32-bit doubles requirement was selected for smaller size.

    Then perhaps the best way to handle it (and other non-obvious oddities) within PropWare is to create a section in the docs for "Quirks and Oddities" that lists noteworthy items like the doubles, header file dependency, and others. Thanks.
Sign In or Register to comment.