/*
* Run the input through the C pre-processor.
+ */
+
+ /*
+ * On OpenSolaris, the default cpp is located in different places.
+ * Alan Coppersmith told me to do what xorg does: using /usr/ccs/lib/cpp
*
+ * Also, that preprocessor is not managing C++ comments, so pass the
+ * sun cc preprocessor just after.
+ */
+ snprintf(buf, sizeof(buf), "/usr/ccs/lib/cpp -I%s %s %s %s",
+ inc, def, file_in, tmpn);
+ ret = system(buf);
+ if (ret == 0)
+ {
+ static char tmpn2[4096];
+
+ snprintf (tmpn2, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmp_dir);
+ fd = mkstemp(tmpn2);
+ if (fd >= 0)
+ {
+ close(fd);
+ snprintf (buf, 4096, "cc -E -I%s %s -o %s %s",
+ inc, def, tmpn2, tmpn);
+ ret = system(buf);
+ snprintf(tmpn, 4096, "%s", tmpn2);
+ }
+ }
+ /*
* On some BSD based systems (MacOS, OpenBSD), the default cpp
* in the path is a wrapper script that chokes on the -o option.
* If the preprocessor is invoked via gcc -E, it will treat
*
* Redirecting the output is required for MacOS 10.3, and works fine
* on other systems.
+ *
+ * FIXME: if C++ comments are still there, maybe doing like on
+ * OpenSolaris: using gcc -E to remove them after using cpp.
+ *
*/
- snprintf(buf, sizeof(buf), "cat %s | cpp -I%s %s > %s",
- file_in, inc, def, tmpn);
- ret = system(buf);
+ if (ret < 0)
+ {
+ snprintf(buf, sizeof(buf), "cat %s | cpp -I%s %s > %s",
+ file_in, inc, def, tmpn);
+ ret = system(buf);
+ }
if (ret < 0)
{
snprintf(buf, sizeof(buf), "gcc -I%s %s -E -o %s %s",